POV-Ray : Newsgroups : povray.general : Bug with noise generator : Bug with noise generator Server Time
5 Nov 2024 05:22:16 EST (-0500)
  Bug with noise generator  
From: Zohar
Date: 27 Jun 2003 17:50:02
Message: <web.3efcbb174718e7c3d0082e520@news.povray.org>
Hi,
I think I found a couple of bugs with the noise generator.
I downloaded the source code for POV-Ray 3.5 for windows, to see how noise
is generated. When reviewing the source, I saw the following:

In the POV-Ray Core project,
in the file "Texture.cpp",
in the function "static void InitSolidNoise (void)",

there is a section of code designed to generate random gradient vectors,
which are  uniformly distributed on the unit sphere. There are 2 bugs with
that:
1. There is a loop there, with a condition that is supposed to "trash" any
random vector which is outside the sphere. The condition should be OR, not
AND:

The code for each random vector generation looks something like that:

   do {
      Find a random vector in the unit cube.
      s = the length of the vector, squared.
   } while ((s > 1.0) && (s < 1.0e-5));

   Normalize the vector;

The condition is a contradiction, and should have been:
   "while ((s > 1.0) || (s < 1.0e-05))"

This bug causes the vectors to be non-uniformly distributed on the sphere.

2. In general, this technique will not produce uniform distribution of
vectors even when the bug is fixed (because the random values are actually
a discrete set of values), but I guess some compromises are tolerable, and
probably invisible (Who can tell that the noise is not exactly uniform?...)

Zohar Leder,
zoh### [at] yahoocom


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.